{template 'common/header'}
<ul class="nav nav-tabs">
    <li  class="active">
        <a href="{php echo $this->createWebUrl('cash', array('op' => 'index'));}">提现列表</a>
    </li>
</ul>
<div class="panel-body">
	<div class="row">
		<div class="col-sm-12 col-md-8">
			<form action="{php echo $this->createWebUrl('cash')}" method="post" class="form-inline" role="form">
				<div class="form-group">
					<select class="form-control" name="states" style="width: 150px;">
						<option {if $states == 0}selected{/if} value="0">全部</option>
						<option {if $states == 1}selected{/if} value="1">待审</option>
						<option {if $states == 2}selected{/if} value="2">已审</option>
					</select>
				</div>
				<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
			</form>
		</div>
	</div>
	<div class="we7-margin-top-sm">
		<table class="table table-bordered we7-form we7-table table-hover vertical-middle">
			<tbody>
				<tr>
					<th style="width:3%;">
						<input type="checkbox" name="check" id="id-0" class="check_all" />
						<label for="id-0">&nbsp;</label>
					</th>
					<th class="text-center" style="width:5%;">提现编号</th>
					<th class="text-center" style="width:10%;">用户UID</th>
					<th class="text-center" style="width:10%;">用户资金明细</th>
					<th class="text-center" style="width:10%;">用户昵称</th>
	                <th class="text-center" style="width:8%;">用户头像</th>
	                <th class="text-center" style="width:5%;">提现金额</th>
					{if $settings['pay_type'] == 1}<th class="text-center" style="width:10%;">支付宝账号</th>{/if}
					{if $settings['pay_type'] == 1}<th class="text-center" style="width:10%;">姓名</th>{/if}
					{if $settings['pay_type'] == 1}<th class="text-center" style="width:10%;">电话</th>{/if}
					{if $settings['pay_type'] == 2}<th class="text-center" style="width:10%;">收款码</th>{/if}
	                <th class="text-center" style="width:8%;">提现时间</th>
	                <th class="text-center" style="width:8%;">审核状态</th>
	                <th class="text-center" style="width:20%;">管理操作</th>
				</tr>
			</tbody>
			{loop $list $row}
			<tr>
				<td style="overflow:hidden;">
					<input type="checkbox" id="id-{$row['cash_id']}" name="check" value="{$row['cash_id']}" />
					<label for="id-{$row['cash_id']}">&nbsp;</label>
				</td>
				<?php
					$user = array();
					if($settings['system_type'] == 1){
						$user = pdo_get($this->modulename . "_user_u", array("unionid" => $row['unionid'],'system_id' => $settings['system_id']));
					}else{
						$user = pdo_get($this->modulename . "_user", array("user_id" => $row['user_id'],'uniacid' => $_W['uniacid']));
					}
					
				?>
				<td class="text-center">{$row['cash_id']}</td>
				<td class="text-center">{$user['uid']}</td>
				<td class="text-center">
					<a class="label label-primary" href="{php echo $this->createWebUrl('cash_user',array('uid'=>$user['uid']))}" title="用户资金明细">资金明细</a>
				</td>
				<td class="text-center">{$row['nickname']}</td>
				<td class="text-center">
					{if !empty($row['avatar'])}
					<img src="{$row['avatar']}" style="width:40px;" />
					{else}
					<img src="/web/resource/images/nopic-107.png" style="width:40px;" />
					{/if}
				</td>
				<td class="text-center">{$row['num']}</td>
				{if $settings['pay_type'] == 1}<td class="text-center">{$row['alipayno']}</td>{/if}
				{if $settings['pay_type'] == 1}<td class="text-center">{$row['realname']}</td>{/if}
				{if $settings['pay_type'] == 1}<td class="text-center">{$row['mobile']}</td>{/if}
				{if $settings['pay_type'] == 2}
				<td class="text-center">
					<a href="{php echo tomedia($row['money_qrcode'])}" target="_blank"><img src="{php echo tomedia($row['money_qrcode'])}" style="width:40px;" /></a>
				</td>
				{/if}
				<td class="text-center">{php echo date('Y-m-d H:i',$row['create_time']);}</td>
				<td class="text-center">
					{if $row['status'] == 0}<span class="label label-default">未支付</span>{/if}
					{if $row['status'] == 1}<span class="label label-success">已支付</span>{/if}
					{if $row['status'] == 2}<span class="label label-danger">已拒绝</span>{/if}
				</td>
	            <td class="text-center">
	                <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('cash', array('op' => 'audit', 'id' => $row['cash_id']))}" title="通过微信企业付款到领取付佣金"><i class="fa fa-check">微信支付</i></a>
	                <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('cash_edit', array('op' => 'post', 'id' => $row['cash_id']))}" title="拒绝"><i class="fa fa-times">拒绝</i></a>
					<a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('cash', array('op' => 'audit2', 'id' => $row['cash_id']))}" title="已手动支付"><i class="fa fa-check">已手动支付</i></a>
	            </td>
			</tr>
			{/loop}
			<tr>
				<td colspan="7">
					<div class="row">
						<div class="col-xs-12 text-left">
							<input name="batch" type="button" data-cmd="audit" data-text="确定要将这些提现通过审核吗?"  class="btn btn-success" value="批量通过" />
							<input type="hidden" name="token" value="{$_W['token']}" />
						</div>
					</div>
				</td>
			</tr>
		</table>
		{if empty($list)}
			<span style="margin-left: 45%;">暂无相关数据</span><br />
		{/if}
		<tr>
			<div class="pull-right">{$pager}</div>
       </tr>
	</div>
</div>
<script>
	$(".check_all").click(function() {
		$("[type='checkbox']").each(function() {
			if($(this).prop("checked")) {
				$(this).attr("checked", false);
				$(".check_all").prop("checked", false);
			} else {
				if($(this).attr("disabled") != "disabled") {
					$(this).prop("checked", true);
					$(".check_all").prop("checked", true);
				}
			}
		});
	});

	// 批量删除
	$("input[name=batch]").click(function() {
		var check = $("input[type=checkbox][class!=check_all]:checked");
		if(check.length < 1) {
			util.message('确认要修改选择要操作的数据！');
			return false;
		}
		var cmd = $(this).data("cmd");
		var text = $(this).data("text");
		util.confirm(function (){
			var id = new Array();
			check.each(function(i) {
				id[i] = $(this).val();
			});
			var url = "{php echo $this->createWebUrl('cash', array('op' => 'batch'))}&cmd=" + cmd;
			$.post(url, {
				'idArr': id
			}, function(data) {
				util.message(data.data);
				top.location.reload();
			}, 'json');
		}, function () {
			return false;
		}, text);
	});

</script>
{template 'common/footer'}